package main
{
	import flash.net.SharedObject;
	
	import struct.TourElementBase;

	public class LocalStoreInfo
	{
		private var _shareObj:SharedObject = SharedObject.getLocal("cookie");
		private var _collectList:Array = [];
		public function LocalStoreInfo()
		{
		}
		
		public function storeInfo(key:String,info:Object):void
		{
			_shareObj.data[key] = info;
		}
		
		/**
		 *  当前存储的信息由 sinaWeibo
		 * 
		 */		
		public function readInfo(key:String):Object
		{
			if(_shareObj.data[key])
			{
				return _shareObj.data[key];
			} 
			return null;
		}
		
		public function clearInfo():void
		{
			_shareObj.clear();
		}
		
		public function storeCollectInfo(cityID:String,type:uint,id:uint,info:Object):void
		{
			storeInfo(cityID + "-" + "type" + "-" + id,{});
		    if(!_shareObj.data["collectInfo"]) _shareObj.data["collectInfo"] = [];
			info.uid = cityID + "-" + "type" + "-" + id;
			_shareObj.data["collectInfo"].push(info);
			
		}
		
		public function removeCollectInfo(cityID:String,type:uint,id:uint):void
		{
			var str:String = cityID + "-" + "type" + "-" + id;
			_shareObj.data[str] = null;
			var list:Array = _shareObj.data["collectInfo"];
			for(var i:int=0;i<list.length;i++)
			{
				if(list[i].uid == str)
				{
					list.splice(i,1);
					_shareObj.data["collectInfo"] = list;
					return;
				}
			}
		}
		
		public function readCollectInfo(cityID:String,type:uint,id:uint):Boolean
		{
			if(readInfo(cityID + "-" + "type" + "-" + id)) return true;
			else return false;
		}
		
		public function get collectList():Array 
		{
			if(!_shareObj.data["collectInfo"]) _shareObj.data["collectInfo"] = [];
			return _shareObj.data["collectInfo"];
		}
		
	}
}